//bg_worker.js
var rs = 0;
var self = this;
function sum() {
  rs += rs;
  //发送数据给主线程
  self.postMessage(rs)
}

//接收主线程发送过来的数据
this.addEventListener('message', (result) => {
  rs = result.data;
  setInterval(() => {
    sum();
  }, 1000)
})